# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=shocker
pkgver=65.65d4d76
pkgrel=3
groups=('blackarch' 'blackarch-exploitation' 'blackarch-scanner')
pkgdesc='A tool to find and exploit servers vulnerable to Shellshock.'
arch=('any')
url='https://github.com/nccgroup/shocker'
license=('GPL3')
depends=('python2')
makedepends=('git')
source=("git+https://github.com/nccgroup/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/usr/bin/python|/usr/bin/python2|' "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"

  install -Dm 644 -t "$pkgdir/usr/share/$pkgname" shocker.py shocker-cgi_list \
    shocker-target_list
  install -Dm 755 "$pkgname.py" "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

